<style type="text/css">
a {
	cursor: pointer;
}
.site.form-group .btn-group, .form-group .group.btn-group, .form-group .from.btn-group, .form-group .from_user.btn-group, .form-group .asign_user.btn-group, .form-group .asign_tips.btn-group, .priority.form-group .btn-group {
	margin-left: 10px;
}
.site .btn-group .dropdown-toggle {
	min-width: 180px;
	text-align: left;
}
.group.btn-group .dropdown-toggle, .from.btn-group .dropdown-toggle, .from_user.btn-group .dropdown-toggle, .asign_user.btn-group .dropdown-toggle, .priority .btn-group .dropdown-toggle {
	min-width: 160px;
	text-align: left;
}
</style>
<link rel="stylesheet" href="/upload/themes/default/default.css" />
<link rel="stylesheet" href="/upload//plugins/code/prettify.css" />
<script charset="utf-8" src="/upload/kindeditor-min.js"></script>
<script charset="utf-8" src="/upload/lang/zh_CN.js"></script>
<script charset="utf-8" src="/upload/plugins/code/prettify.js"></script>
<script>
var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="editor"]', {
		allowFileManager : true
	});
});
</script>
<div class="pageheader">
	<h2>
		<i class="fa fa-sitemap"></i>办公管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>办公管理</li>
			<li class="active">发布需求</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
    <div class="main">
    <form action="/office/pubneed" method="post" class="form-horizontal">
        <?php if ($this->msg):?>
        <div style="margin: 20px 184px;" class="form-group"><?php foreach ($this->msg as $v):?><span class="label label-warning"><?php echo $v;?></span><?php endforeach;?></div>
        <?php endif;?>  
        <div class="form-group form-inline">
            <label for="Title" class="col-sm-2 control-label">摘要：</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="title" size="100">
            </div>
        </div>
        <div class="form-group site">
            <label for="Site" class="col-sm-2 control-label">网站：</label>
            <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择网站 </span></button>
                <input type="hidden" value="0" name="site">
                <ul class="dropdown-menu">
                    <li><a>gogoalshop.com</a></li>
                    <li><a>elmontyouthsoccer.com</a></li>
                    <li><a>bestcheapsoccer.com</a></li>
                    <li><a>minejerseys.com</a></li>
                    <li><a>jerseysmark.com</a></li>
                    <li><a>goaljerseys.com</a></li>
                    <li><a>fancybestdeal.com</a></li>
                    <li><a>ERP-System.com</a></li>
                    <li><a>B2B2C-Mall-Platform.com</a></li>
               </ul>
            </div>
        </div>
        <div class="form-group form-inline">
            <label for="Content" class="col-sm-2 control-label">详情：</label>
            <div class="col-sm-10">
                <textarea id="editor" name="editor" style="width:800px;height:360px;visibility:hidden;">可以添加图片和文档了</textarea>
            </div>
        </div>
        <div class="form-group form-inline">
            <label for="Needfrom" class="col-sm-2 control-label">需求来自：</label>
            <div class="btn-group from">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text"><?php echo $this->user;?> </span></button>
                <input type="hidden" value="0" name="from">
                <ul class="dropdown-menu">
                    <li><a data-id="1">管理团队</a></li>
                    <li><a data-id="2">运营团队</a></li>
                    <li><a data-id="3">技术团队</a></li>
                    <li><a data-id="4">仓储行政团队</a></li>
               </ul>
            </div>
            <div class="btn-group from_user hidden">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择成员 </span></button>
                <input type="hidden" value="0" name="from_user">
                <ul class="dropdown-menu">
                
               </ul>
            </div>
        </div>
        <div class="form-group form-inline needasign">
            <label for="Needasign" class="col-sm-2 control-label">需求指派：</label>
            <div class="btn-group group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择团队 </span></button>
                <input type="hidden" value="0" name="group[]">
                <ul class="dropdown-menu">
                    <li><a data-id="1">管理团队</a></li>
                    <li><a data-id="2">运营团队</a></li>
                    <li><a data-id="3">技术团队</a></li>
                    <li><a data-id="4">仓储行政团队</a></li>
               </ul>
            </div>
            <div class="btn-group asign_user">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择成员 </span></button>
                <input type="hidden" value="" name="asign_user[]">
                <ul class="dropdown-menu">
                
               </ul>
            </div>
            <div class="btn-group asign_tips">
                <a href="javascript:void(0);" onclick="addAsignUser(this)" class="btn btn-default "><i class="fa fa-plus-square-o"></i></a>
            </div>
        </div>
        <div class="form-group priority">
            <label for="Priority" class="col-sm-2 control-label">优先级：</label>
            <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择优先级 </span></button>
                <input type="hidden" value="0" name="priority">
                <ul class="dropdown-menu">
                    <li><a data-id="0">默认等待</a></li>
                    <li><a data-id="1">比较重要</a></li>
                    <li><a data-id="2">十分紧急</a></li>
               </ul>
            </div>
        </div>
        <div class="form-group form-inline">
            <label for="Memo" class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-10">
                <textarea rows="2" cols="100" class="form-control" name="memo"></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </div>
    </form>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	 $(".site li a").click(function(){
	     $(".site .text").text($(this).text());
         $(".site input").val($(this).text());
     });
	 $(".from li a").click(function(){
	     $(".from .text").text($(this).text());
	     $.get("/office/loaduser", {group:$(this).data('id')},
	    	 function(data){
	    	     $(".from_user .dropdown-menu").html(data.content);
	    	     $(".from_user .text").text('请选择成员');
	    	     $(".from_user").removeClass("hidden");
		     },'json'
		 );
     });
	 $(".group li a").live('click',function(){
		 var $needasign = $(this).parent().parent().parent().parent();
		 $needasign.children('.group').children('button').children('.text').text($(this).text());
	     $needasign.children('.group').children('input').val($(this).data('id'));
	     $.get("/office/loaduser", {group:$(this).data('id')},
	    	 function(data){
	    	     $needasign.children(".asign_user").children(".dropdown-menu").html(data.content);
	    	     $needasign.children(".asign_user").children("button").children(".text").text('请选择成员');
		     },'json'
		 );
     });
	 $(".asign_user li a").live('click',function(){
		 var $asignuser = $(this).parent().parent().parent();
	     $asignuser.children("button").children(".text").text($(this).text());
	     $asignuser.children("input").val($(this).data('id'));
     });
	 $(".from_user li a").live('click',function(){
	     $(".from_user .text").text($(this).text());
	     $(".from_user input").val($(this).data('id'));
     });
	 $(".priority li a").click(function(){
	     $(".priority .text").text($(this).text());
	     $(".priority input").val($(this).data('id'));
     });
});

//增加指派
function addAsignUser(obj) {
	var content = '<div class="form-group form-inline needasign"><label for="Needasign" class="col-sm-2 control-label"></label><div class="btn-group group">'+
        '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择团队 </span></button>'+
        '<input type="hidden" value="0" name="group[]"><ul class="dropdown-menu"><li><a data-id="1">管理团队</a></li><li><a data-id="2">运营团队</a></li>'+
        '<li><a data-id="3">技术团队</a></li><li><a data-id="4">仓储行政团队</a></li></ul></div><div class="btn-group asign_user">'+
        '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="text">请选择成员 </span></button>'+
        '<input type="hidden" value="" name="asign_user[]"><ul class="dropdown-menu"></ul></div><div class="btn-group asign_tips">'+
        '<a href="javascript:void(0);" onclick="addAsignUser(this)" class="btn btn-default "><i class="fa fa-plus-square-o"></i></a>'+
        '<a href="javascript:void(0);" onclick="minusAsignUser(this)" class="btn btn-default "><i class="fa fa-minus-square-o"></i></a></div></div>';
    $(".needasign:last").after(content);
}
function minusAsignUser(obj) {
	$(obj).parent().parent().remove();
}
</script>